package com.lollipop.synthential.examination;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author: Lollipop
 * @Date: 2021-05-28 10:57
 * @Description: 我国古代数学家张丘建在《算经》一书中曾提出过著名的“百钱买百鸡”问题。
 * 该问题叙述如下：鸡翁一，值钱五；鸡母一，值钱三；鸡雏三，值钱一；百钱买百鸡，则翁、母、雏各几何？
 */
@Slf4j
public class BuyChicken {
    public static void main(String[] args) {
        int roosterCount = 20, henCount = 33, chickenCount = 100;
        int count = 0;
        for (int i = 0; i < roosterCount; i++) {
            for (int j = 0; j < henCount; j++) {
                for (int k = 0; k < chickenCount; k++) {
                    if (i + j + k == 100 && 5 * i + 3 * j + k / 3 == 100 && k % 3 == 0) {
                        log.info("公鸡、母鸡、小鸡各为：{{},{},{}}", i, j, k);
                    }
                    count++;
                }
            }
            log.info("循环次数：{}", count);
        }
    }
}
